﻿namespace duia.Canteenpay.Domain.DomainObject
{
    /// <summary>
    /// 系统用户表
    /// </summary>
    public class Users : BaseEntity, IAggregateRoot
    {
        #region 成员变量
        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 用户密码
        /// </summary>
        public string UserPassWord { get; set; }

        /// <summary>
        /// 登录账号
        /// </summary>
        public string Account { get; set; }

        #endregion

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="userName">用户姓名</param>
        /// <param name="userPassWord">密码</param>
        /// <param name="account">账号</param>
        public Users(string userName, string userPassWord, string account)//, Guid? keyId = null
        {
            //if (keyId.HasValue) base.SetKeyId(keyId.Value);
            this.UserPassWord = !string.IsNullOrEmpty(userPassWord) ? userPassWord : throw new DomainException(nameof(userPassWord));
            this.UserName = !string.IsNullOrEmpty(userName) ? userName : throw new DomainException(nameof(userName));
            this.Account = !string.IsNullOrEmpty(account) ? account : throw new DomainException(nameof(account));
        }

        /// <summary>
        /// 设置用户姓名
        /// </summary>
        /// <param name="value"></param>
        public void SetUserName(string value)
        {
            this.UserName = !string.IsNullOrEmpty(value) ? value : throw new DomainException(nameof(value));

        }

        /// <summary>
        /// 设置用户密码
        /// </summary>
        /// <param name="value"></param>
        public void SetUserPassWord(string value)
        {
            this.UserPassWord = !string.IsNullOrEmpty(value) ? value : throw new DomainException(nameof(value));

        }

        /// <summary>
        /// 设置用户账号
        /// </summary>
        /// <param name="value"></param>
        public void SetAccount(string value)
        {
            this.Account = !string.IsNullOrEmpty(value) ? value : throw new DomainException(nameof(value));

        }
    }
}
